#ifndef WINDOW_H
#define WINDOW_H

#include <QMainWindow>
#include <QUrl>
#include <QWebView>
#include <QWebElement>
#include "configSet.h"


QT_BEGIN_NAMESPACE
class QTreeWidgetItem;
QT_END_NAMESPACE

//! [Window class definition]
#include "ui_window.h"



class Window : public QMainWindow, private Ui::Window
{
    Q_OBJECT

public:
    Window(QWidget *parent = 0);
    ~Window();
    void setUrl(const QUrl &url);
    void mouseReleaseBtn();

public slots:
    void on_webView_loadFinished();
    void on_seach_btn_clicked();

private slots:
    void on_webView_linkClicked(const QUrl &arg1);
    void on_checkBox_clicked(bool checked);


//    void on_checkBox_clicked(bool checked);

    void on_lineEdit_returnPressed();

    void setClipboard();   //设置剪贴板的内容
    void getClipboard();   //获取剪贴板的内容
    void clipboardChanged();

private:
    void examineChildElements(const QWebElement &parentElement,
                              QTreeWidgetItem *parentItem);
    QString siteStr;
    QWebView * addWebView(QString defualtUrlStr);
    QMap<QString,QWebView*> m_webViewMap;
    ConfigSet *m_pConfigSet;
    void initCheckBox();
    bool fixTheUrlStr(QString searchUrl, QString keyword, QString &urlStr);
    void setUrl(QString searchUrl,QString keyword);
    QString saveTempHtmlFromXML(QString xmlStr,QString tempName = "temp.html");
    bool isFinshed;



 protected:
    typedef struct{
        bool isTrue;
        QString seach_world;
    }is_seach_result;
    bool isSeachSite(QString keyword, QString &seach_keyword);
    bool isSeachTitle(QString keyword, QString &seach_keyword);
    bool isSeachDomain(QString keyword,QString &seach_keyword);
    bool isSeachInurl(QString keyword,QString &seach_keyword);
    bool isSeachIntitle(QString keyword,QString &seach_keyword);
};
//! [Window class definition]

#endif
